-[CCScene setOffsetx:]: unrecognized selector sent to instance

Posted by Alexander Sharunov on Stack Overflow See other posts from Stack Overflow or by Alexander Sharunov
Published on 2012-03-23T05:05:07Z Indexed on 2012/03/23 5:29 UTC
Read the original article Hit count: 206

Filed under:
|
|

please help me, i'm very new in objective-c

i've got 2 simplest classes (bellow first, second)

i would like to set the offsetx properties of self.rolypoly object in second class like a self.rolypoly.offsetx=1 or run use [self.rolypoly setOffx]; to do somethings, but i always have the errors:

trying [self.rolypoly setOffx]; in second class

-[CCScene setOffx:]: unrecognized selector sent to instance 0x91d0b70'

or

trying self.rolypoly.offsetx=1; in second class

-[CCScene setOffsetx:]: unrecognized selector sent to instance 0x808bfc0'

first class

//************************************************************ 
       #import <Foundation/Foundation.h>
        #import "cocos2d.h"

        @interface RolyPoly : CCLayer {

            CCAction *_walkAction; 
            CCSprite *_rolypoly;
            int offsetx;
            int offsety;
        }

        @property (nonatomic, retain) CCSprite *rolypoly;
        @property (nonatomic, retain) CCAction *walkAction;
        @property (nonatomic, assign) int offsetx;
        @property (nonatomic, assign) int offsety;

        +(id) scene;
        -(void) setOffx;
        @end
//************************************************************     
        #import "GameLayer.h"
        #import "RolyPoly.h"

        @implementation RolyPoly

        @synthesize rolypoly = _rolypoly;
        @synthesize walkAction = _walkAction;
        @synthesize  offsetx = _offsetx;
        @synthesize  offsety = _offsety;

        +(id) scene
        {
            CCScene *scene = [CCScene node];

            RolyPoly *layer = [RolyPoly node];

            [scene addChild: layer];

            return scene;
        }

        -(id) init
        {
            if ((self = [super init]))
            {

                [self scheduleUpdate];
            }
            return self;
        }
        -(void) setOffx
        {

            NSLog(@"setOffx");
        }

        -(void) update:(ccTime)delta
        {

        }
        - (void) dealloc
        {
            self.rolypoly = nil;
            self.walkAction = nil;
            [super dealloc];
        }
        @end

second class

//************************************************************ 
    #import <Foundation/Foundation.h>
    #import "cocos2d.h"
    #import "RolyPoly.h"


    @interface GameLayer : CCLayer {

        RolyPoly *_rolypoly;
    }

    // returns a CCScene that contains the HelloWorldLayer as the only child
    +(CCScene *) scene;
    @property (nonatomic, assign) RolyPoly * rolypoly;

    @end

//************************************************************   
    #import "GameLayer.h"
    #import "RolyPoly.h"

    // HelloWorldLayer implementation
    @implementation GameLayer

    @synthesize  rolypoly = _rolypoly;

    +(CCScene *) scene
    {
        CCScene *scene = [CCScene node];
        GameLayer *layer = [GameLayer node];
        [scene addChild: layer];
        return scene;
    }

    -(id) init
    {
        if( (self=[super init])) {

            CGSize screenSize = [[CCDirector sharedDirector] winSize];

            self.rolypoly = [RolyPoly scene];
            [self addChild:self.rolypoly z:1];
            [self.rolypoly setOffx];
            [self scheduleUpdate];

        }
        return self;
    }


    - (void)update:(ccTime)dt {

    }

    - (void) dealloc
    {
        [super dealloc];
    }
    @end

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocos2d